<template>
  <div>
    <div class="card">
      <div class="card-body">
        <div class="d-flex">
          <div class="item-label">解保类型：</div>
          <div :class="`text-${enumStyle[relatedData.un_gua_type]}`">
            {{ enumLoanUnStatus[relatedData.un_gua_type] || '-' }}
          </div>
        </div>
        <div class="d-flex my-2">
          <div class="item-label">解保时间：</div>
          <div>{{ unDate || '-' }}</div>
        </div>
        <div class="d-flex my-2">
          <div class="item-label">解保金额：</div>
          <div>{{ relatedData.un_gua_funds || '-' }} 万元</div>
        </div>
        <div class="d-flex">
          <div class="item-label">解保清单：</div>
          <div class="flex-1">
            <div v-for="(file, index) of attachImages" :key="index">
              <attach-item :attach-data="file"></attach-item>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { enumLoanUnStatus } from '@/bank/views/limit/index'
import { arrayFromString } from '@vimi/utils-tool'
import AttachItem from '@/bank/components/attach/Item'
import { attachAdapter } from '@/bank/components/attach/index'
export default {
  components: {
    AttachItem,
  },
  props: {
    relatedData: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      enumStyle: {
        4: 'primary',
        5: 'success',
        6: 'danger',
      },
      enumLoanUnStatus,
    }
  },
  computed: {
    unDate() {
      return this.$utils.dateFormat(this.relatedData.un_gua_date, 'yyyy年MM月dd日')
    },
    attachImages() {
      return arrayFromString(this.relatedData.un_gua_attachment).map(item => {
        return attachAdapter({ attachment: item })
      })
    },
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {},
}
</script>

<style lang="scss" scoped>
.item-label {
  width: 120px;
}
</style>
